package com.example.httpdemo.controller;

import com.example.common.global.BaseController;
import com.example.common.global.CommonResponse;
import org.springframework.web.bind.annotation.*;

/**
 * @author Aaron
 * @since 2021/9/6 14:03
 * <p>描述：</p>
 */
@RestController
@RequestMapping("/method")
public class MethodController extends BaseController {

    @RequestMapping(path = "/get", method = RequestMethod.GET)
    public CommonResponse<?> get() {
        // 调用 POST http://localhost:8192/method/get 返回：405 Method Not Allowed
        return success("RequestMapping Get Success!");
    }

    @GetMapping(path = "/getMapping")
    public CommonResponse<?> getMapping() {
        // 调用 POST http://localhost:8192/method/getMapping 返回：405 Method Not Allowed
        return success("GetMapping Success!");
    }

    @RequestMapping(path = "/post", method = RequestMethod.POST)
    public CommonResponse<?> post() {
        // 调用 Get http://localhost:8192/method/post 返回：405 Method Not Allowed
        return success("RequestMapping Post Success!");
    }

    @PostMapping(path = "/postMapping")
    public CommonResponse<?> postMapping() {
        // 调用 Get http://localhost:8192/method/postMapping 返回：405 Method Not Allowed
        return success("PostMapping Success!");
    }

    @RequestMapping("/noMethod")
    public CommonResponse<?> noMethod() {
        // 调用 Get/Post http://localhost:8192/method/noMethod 均成功
        return success("noMethod Success!");
    }

}
